package com.appbee.yahoo.query.client.search;

import javax.inject.Singleton;

import com.google.gwt.core.client.GWT;
import com.google.gwt.jsonp.client.JsonpRequestBuilder;

@Singleton
public class YqlMusicService
{
	private String baseUrl = "http://query.yahooapis.com/v1/public/yql?format=json&q=select title,releaseYear,Artist.name,Album.Release.title,Category.name,Category.type from music.track.search where keyword=\"";
	
	public void findByTrack(String name,TrackQueryCallback callback)
	{
		StringBuffer url = new StringBuffer();
		url.append(baseUrl);
		url.append(name);
		url.append("\"");
		GWT.log("Yahoo query: "+url.toString());
		JsonpRequestBuilder rb = new JsonpRequestBuilder();
		rb.requestObject(url.toString(), callback);
	}
}
